from django.contrib import admin
from django.urls import path, include
from django.http import HttpResponse

def home_view(request):
    html = """
    <!DOCTYPE html>
    <html>
        <head>
            <title>药匣子后台管理系统</title>
            <meta charset="utf-8">
            <style>
                body { font-family: Arial, sans-serif; margin: 40px; }
                h1 { color: #333; }
                .links { margin-top: 20px; }
                .links a { 
                    display: inline-block; 
                    margin: 10px; 
                    padding: 10px 20px; 
                    background-color: #007bff; 
                    color: white; 
                    text-decoration: none; 
                    border-radius: 5px; 
                }
                .links a:hover { background-color: #0056b3; }
                .api-section { margin-top: 30px; padding: 20px; background-color: #f8f9fa; border-radius: 5px; }
            </style>
        </head>
        <body>
            <h1>欢迎使用药匣子后台管理系统</h1>
            <p>家庭药品智能管理与应急辅助系统</p>
            
            <div class="links">
                <a href="/admin/">管理后台登录</a>
                <a href="/api/medicines/">药品API接口</a>
                <a href="/api/families/">家庭API接口</a>
                <a href="/api/reminders/">用药提醒API接口</a>
            </div>
            
            <div class="api-section">
                <h2>API接口说明</h2>
                <p>本系统提供RESTful API接口，供前端应用（如微信小程序）调用：</p>
                <ul>
                    <li>药品管理接口：/api/medicines/</li>
                    <li>家庭管理接口：/api/families/</li>
                    <li>用药提醒接口：/api/reminders/</li>
                    <li>应急服务接口：/api/emergency/</li>
                    <li>库存管理接口：/api/inventory/</li>
                    <li>通知反馈接口：/api/notifications/</li>
                    <li>第三方服务接口：/api/third-party/</li>
                </ul>
            </div>
        </body>
    </html>
    """
    return HttpResponse(html.encode('utf-8'))

urlpatterns = [
    path('', home_view),
    path('admin/', admin.site.urls),
    path('api/medicines/', include('medicines.urls')),
    path('api/families/', include('families.urls')),
    path('api/emergency/', include('emergency.urls')),
    path('api/reminders/', include('reminders.urls')),
    path('api/inventory/', include('inventory.urls')),
    path('api/notifications/', include('notifications.urls')),
    path('api/third-party/', include('third_party.urls')),
]